babl: fix clang warnings in babl-polynomial
authorEll <ell_se@yahoo.com>
Tue, 3 Oct 2017 14:01:58 +0000 (10:01 -0400)
committerEll <ell_se@yahoo.com>
Tue, 3 Oct 2017 14:05:52 +0000 (10:05 -0400)
Cast the input polynomial from BablPolynomial* to
BablBigPolynomial* in the evaluator functions, so that clang
doesn't warn us about out-of-bounds access to its coefficient
array.

babl/babl-polynomial.c

index 82f9ce4d3e4d95bd6d04f90311e6827975961936..d27c1bb93cdd5ac065671249180e6598d4476505 100644 (file)
@@ -98,10 +98,14 @@ typedef struct
   babl_polynomial_eval_1_##i (const BablPolynomial *poly,                      \
                               double                x)                         \
   {                                                                            \
+    /* quiet clang warnings */                                                 \
+    const BablBigPolynomial *const big_poly = (const BablBigPolynomial *) poly;\
+                                                                               \
     const double x2 = x * x;                                                   \
     (void) x2;                                                                 \
-    return BABL_POLYNOMIAL_EVAL_##i   (poly, x2) +                             \
-           BABL_POLYNOMIAL_EVAL_##i_1 (poly, x2) * x;                          \
+                                                                               \
+    return BABL_POLYNOMIAL_EVAL_##i   (big_poly, x2) +                         \
+           BABL_POLYNOMIAL_EVAL_##i_1 (big_poly, x2) * x;                      \
   }
 #include "babl-polynomial.c"
 
@@ -110,8 +114,11 @@ typedef struct
   babl_polynomial_eval_2_##i (const BablPolynomial *poly,                      \
                               double                x)                         \
   {                                                                            \
-    return BABL_POLYNOMIAL_EVAL_##i   (poly, x) +                              \
-           BABL_POLYNOMIAL_EVAL_##i_1 (poly, x) * sqrt (x);                    \
+    /* quiet clang warnings */                                                 \
+    const BablBigPolynomial *const big_poly = (const BablBigPolynomial *) poly;\
+                                                                               \
+    return BABL_POLYNOMIAL_EVAL_##i   (big_poly, x) +                          \
+           BABL_POLYNOMIAL_EVAL_##i_1 (big_poly, x) * sqrt (x);                \
   }
 #include "babl-polynomial.c"